# -*- coding: utf-8 -*-
"""
魔法函数 __getitem__ 可以使对象具有切片功能
"""
from typing import List


class Company:
    def __init__(self, staffs: List):
        self.staffs = staffs

    def __getitem__(self, item):
        """切片操作时运行该魔法函数"""
        return self.staffs[item]

    def __iter__(self):
        """迭代操作时运行该魔法函数"""
        for staff in self.staffs:
            yield staff

    def __len__(self):
        return len(self.staffs)


if __name__ == '__main__':
    company = Company(['a','b','c'])
    for item in company:
        print(item)

    print(len(company))